package followme.yaohuile.com.followme.adapter.recommend.destination;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.BitmapUtils;

import java.util.List;

import followme.yaohuile.com.followme.R;
import followme.yaohuile.com.followme.bean.recommend.destination.CountryInfo;


/**
 * Created by Administrator on 15-11-14.
 */
public class HotCountryAdapter extends BaseAdapter{
    List<CountryInfo> hotcountrylist;
    Context context;
    BitmapUtils bitmapUtils;
    public HotCountryAdapter(Context context, List<CountryInfo> hotcountrylist,BitmapUtils bitmapUtils) {
        this.context = context;
        this.hotcountrylist = hotcountrylist;
        this.bitmapUtils = bitmapUtils;
    }

    @Override
    public int getCount() {
        return hotcountrylist.size();
    }

    @Override
    public Object getItem(int position) {
        return hotcountrylist.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder vh;
        if (convertView==null){
            vh = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.hotcountryitem,null);
            vh.image = (ImageView) convertView.findViewById(R.id.hotCountry);
            vh.catename = (TextView) convertView.findViewById(R.id.name);
            vh.catename_en = (TextView) convertView.findViewById(R.id.eg_name);
            vh.count = (TextView) convertView.findViewById(R.id.count);
            vh.label = (TextView) convertView.findViewById(R.id.label);
            convertView.setTag(vh);
        }else{
            vh = (ViewHolder) convertView.getTag();
        }
        vh.catename.setText(hotcountrylist.get(position).getCatename());
        vh.catename_en.setText(hotcountrylist.get(position).getCatename_en());
        vh.count.setText(hotcountrylist.get(position).getCount());
        vh.label.setText(hotcountrylist.get(position).getLabel());
        bitmapUtils.display(vh.image, hotcountrylist.get(position).getPhoto());
        return convertView;
    }
    class ViewHolder{
        ImageView image;
        TextView catename;
        TextView catename_en;
        TextView count;
        TextView label;
    }
}


